#include <cmath>
#include <cstdio>

const int N = 21;
int n, w[N];
double p[N], f[1 << N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("gift.in", "r", stdin);
  freopen("gift.out", "w", stdout);
#endif
#endif

  scanf("%d", &n);
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%lf%d", &p[i], &w[i]);
    ans += w[i];
  }
  for (int i = 1; i < (1 << n); ++i) {
    double sum = 0.0;
    for (int j = 1; j <= n; ++j) {
      if (i & (1 << (j - 1))) {
        sum += p[j];
        f[i] += p[j] * f[i ^ (1 << (j - 1))];
      }
    }
    f[i] += 1;
    f[i] /= sum;
  }
  printf("%lld\n%.3lf", ans, f[(1 << n) - 1]);
  return 0;
}